package com.meilele.dao.hongdian;

import com.meilele.entity.hongdian.ThiImages;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
public interface ThiImagesMapper {
    @Delete({
        "delete from thi_images",
        "where image_id = #{imageId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer imageId);

    @Insert({
        "insert into thi_images (image_id, image_img, ",
        "image_name, image_desc, ",
        "show_id)",
        "values (#{imageId,jdbcType=INTEGER}, #{imageImg,jdbcType=VARCHAR}, ",
        "#{imageName,jdbcType=VARCHAR}, #{imageDesc,jdbcType=VARCHAR}, ",
        "#{showId,jdbcType=INTEGER})"
    })
    int insert(ThiImages record);

    int insertSelective(ThiImages record);

    @Select({
        "select",
        "image_id, image_img, image_name, image_desc, show_id",
        "from thi_images",
        "where image_id = #{imageId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.hongdian.ThiImagesMapper.BaseResultMap")
    ThiImages selectByPrimaryKey(Integer imageId);

    int updateByPrimaryKeySelective(ThiImages record);

    @Update({
        "update thi_images",
        "set image_img = #{imageImg,jdbcType=VARCHAR},",
          "image_name = #{imageName,jdbcType=VARCHAR},",
          "image_desc = #{imageDesc,jdbcType=VARCHAR},",
          "show_id = #{showId,jdbcType=INTEGER}",
        "where image_id = #{imageId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ThiImages record);

	@Select("SELECT COUNT(image_id) FROM thi_images WHERE show_id = #{showId}")
    long findCount(int showId);

	@Delete("DELETE FROM thi_images WHERE show_id = #{showId}")
    int deleteImages(int showId);

	@Update("UPDATE thi_images SET \n" +
            "image_id = #{imageId}, image_img = #{imageImg}, image_name = #{imageName}, \n" +
            "image_desc = #{imageDesc}, show_id = #{showId} WHERE show_id = #{showId}")
	int updateImages(int showId);
}